export const to = (path, params = null) => {
	let query = ''
	let url = path
	if (params !== null) {
		for (let key in params) {
			if (key == Object.keys(params)[0]) {
				query = `?${key}=${params[key]}`
			} else {
				query += `&${key}=${params[key]}`
			}
		}
		url += query
	}
	uni.navigateTo({
		url
	})
}

export const tar = (path, params = null) => {
	let query = ''
	let url = path
	if (params !== null) {
		for (let key in params) {
			if (key == Object.keys(params)[0]) {
				query = `?${key}=${params[key]}`
			} else {
				query += `&${key}=${params[key]}`
			}
		}
		url += query
	}
	uni.switchTab({
		url
	})
}

export const back = (delta = 1) => {
	uni.navigateBack({
		delta
	})
}

export const redirec = (url) => {
	uni.redirectTo({
		url
	})
}
